import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { SPlayerOlympicGuessInfo } from "../../../../../Message/Game/SPlayerOlympicGuessInfo";
import { OlympicGuessDataParser } from "../data/OlympicGuessDataParser";
import { OlympicGuessData } from "../data/OlympicGuessData";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { OlympicGuessTodayWin } from "./OlympicGuessTodayWin";
import { OlympicGuessMostGoldWin } from "./OlympicGuessMostGoldWin";
import { OlympicGuessTotalWin } from "./OlympicGuessTotalWin";
import { GTabBar } from "../../../../../com/mui/controls/GTabBar";
import { MuiEvent } from "../../../../../com/mui/events/MuiEvent";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { OlympicGuessAllData } from "../data/OlympicGuessAllData";
type int = number;
//class OlympicGuessWin
    
    export  class OlympicGuessWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(this.WinWidth, this.WinHeight);
            this.title = Language.getString(80000);
            this.titleHeight = 27;
            this._isResFileGot = false;
            this.initView();
            return;
        }

        public changeTab(arg1: string): void
        {
            if (!this._isResFileGot) 
            {
                return;
            }
            this._guessToday.visible = false;
            this._guessTotal.visible = false;
            this._guessMost.visible = false;
            var loc1=arg1;
            switch (loc1) 
            {
                case this.NameToday:
                {
                    this._guessToday.visible = true;
                    break;
                }
                case this.NameTotal:
                {
                    this._guessTotal.visible = true;
                    break;
                }
                case this.NameMost:
                {
                    this._guessMost.visible = true;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        public updateGuessTodayData(arg1: SPlayerOlympicGuessInfo): void
        {
            if (arg1 == null) 
            {
                return;
            }
            this._myData = new OlympicGuessDataParser().parseData(arg1);
            if (!this._isResFileGot) 
            {
                return;
            }
            this._guessToday.updateDatas(this._myData);
            this._guessMost.updateData(this._myData);
            this._guessTotal.updateData(this._myData);
            return;
        }

        public expandGuessTodayItem(arg1: OlympicGuessData): void
        {
            if (!this._isResFileGot) 
            {
                return;
            }
            this._guessToday.expandGuessTodayItem(arg1);
            return;
        }

        public changeAnswerTipsToExpandType(): void
        {
            this._guessToday.changeAnswerTipsToExpandType();
            return;
        }

        public changeAnswerTipsToShrinType(): void
        {
            this._guessToday.changeAnswerTipsToShrinType();
            return;
        }

        /* internal  */initView(): void
        {
            this._bg = new Object /* flash.display.Bitmap */();
            this._bg.x = 19;
            this._bg.y = 39;
            this.addChild(this._bg);
            LoaderHelp.addResCallBack(ResFileConst.OlympicGuess, this.getBgHandler);
            return;
        }

        /* internal  */getBgHandler(): void
        {
            this._isResFileGot = true;
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.OlympicGuessBg);
            this.continueInitView();
            Dispatcher.dispatchEvent(new DataEvent(EventName.OlympicGuessResFileGot));
            return;
        }

        /* internal  */continueInitView(): void
        {
            var loc1=19;
            var loc2=166;
            ObjCreate.createBg(loc1, loc2, 693, this.WinHeight - 162 - 14, this);
            this.initTabBar(8, loc2 + 10);
            var loc3=ObjCreate.createGTextField("", loc1 + 38, loc2 + 48, 200, 20, this);
            var loc4;
            (loc4 = loc3.defaultTextFormat).bold = true;
            loc3.defaultTextFormat = loc4;
            loc3.htmlText = Language.getString(80004);
            loc3 = ObjCreate.createGTextField("", loc1 + 38 + 225, loc3.y, 200, 20, this);
            (loc4 = loc3.defaultTextFormat).bold = true;
            loc3.defaultTextFormat = loc4;
            loc3.htmlText = Language.getString(80005);
            loc3 = ObjCreate.createGTextField("", loc1 + 38 + 450, loc3.y, 200, 20, this);
            (loc4 = loc3.defaultTextFormat).bold = true;
            loc3.defaultTextFormat = loc4;
            loc3.htmlText = Language.getString(80006);
            this._guessToday = new OlympicGuessTodayWin();
            this._guessToday.x = loc1 + 2;
            this._guessToday.y = loc2 + 68;
            this.addChild(this._guessToday);
            this._guessMost = new OlympicGuessMostGoldWin();
            this._guessMost.x = loc1 + 2;
            this._guessMost.y = loc2 + 68;
            this.addChild(this._guessMost);
            this._guessMost.visible = false;
            this._guessTotal = new OlympicGuessTotalWin();
            this._guessTotal.x = loc1 + 2;
            this._guessTotal.y = loc2 + 68;
            this.addChild(this._guessTotal);
            this._guessTotal.visible = false;
            return;
        }

        /* internal  */initTabBar(arg1: int, arg2: int): void
        {
            var loc1=null;
            this._pageTabBar = new GTabBar();
            this._pageTabBar.x = arg1;
            this._pageTabBar.y = arg2;
            this._pageTabBar.buttonHeight = 37;
            this._pageTabBar.buttonWidth = 189;
            this._pageTabBar.horizontalGap = 36;
            this._pageTabBar.buttonStyleName = "OlympicGuessTabBtn";
            this._pageTabBar.dataProvider = [{"name":"OlympicGuessTabBtn1", "label":" "}, {"name":"OlympicGuessTabBtn2", "label":" "}, {"name":"OlympicGuessTabBtn3", "label":" "}];
            this._pageTabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.pageBarChangeHandler);
            this.addChild(this._pageTabBar);
            loc1 = new Object /* flash.display.Bitmap */(GlobalClass.getBitmapData(ImagesConst.OlympicGuessActivity1));
            loc1.x = 64;
            loc1.y = arg2 + 10;
            this.addChild(loc1);
            var loc2;
            (loc2 = new Object /* flash.display.Bitmap */()).bitmapData = GlobalClass.getBitmapData(ImagesConst.OlympicGuessActivity2);
            loc2.x = 289;
            loc2.y = arg2 + 10;
            this.addChild(loc2);
            var loc3;
            (loc3 = new Object /* flash.display.Bitmap */()).bitmapData = GlobalClass.getBitmapData(ImagesConst.OlympicGuessActivity3);
            loc3.x = 514;
            loc3.y = arg2 + 10;
            this.addChild(loc3);
            return;
        }

        /* internal  */pageBarChangeHandler(arg1: MuiEvent): void
        {
            var loc1=this._pageTabBar.selectedIndex;
            var loc2=this.NameToday;
            if (loc1 != 1) 
            {
                if (loc1 == 2) 
                {
                    loc2 = this.NameMost;
                }
            }
            else 
            {
                loc2 = this.NameTotal;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.OlympicGuessClickChangeTab, loc2));
            return;
        }

        /* internal */ /* const */WinWidth: int=731;

        /* internal */ /* const */WinHeight: int=515;

        /* internal */ /* const */GuessWinStartX: int=40;

        /* internal */ /* const */GuessWinStartY: int=60;

        /* internal */ /* const */NameToday: string="NameToday";

        /* internal */ /* const */NameTotal: string="NameTotal";

        /* internal */ /* const */NameMost: string="NameMost";

        /* internal */ /* var */_btnToday: GLoadedButton;

        /* internal */ /* var */_btnTotal: GLoadedButton;

        /* internal */ /* var */_btnMost: GLoadedButton;

        /* internal */ /* var */_guessToday: OlympicGuessTodayWin;

        /* internal */ /* var */_guessTotal: OlympicGuessTotalWin;

        /* internal */ /* var */_guessMost: OlympicGuessMostGoldWin;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_pageTabBar: GTabBar;

        /* internal */ /* var */_myData: OlympicGuessAllData;

        /* internal */ /* var */_isResFileGot: Boolean;
    }
